package com.youdianda.controller;


import com.youdianda.dto.MemberManagementAddDTO;
import com.youdianda.dto.MemberManagementPageDTO;
import com.youdianda.dto.MemberManagementUpDTO;
import com.youdianda.result.Result;

import com.youdianda.service.ISysUserService;
import com.youdianda.vo.MemberManagementpageVo;
import com.youdianda.vo.MemberManagementqueVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author mosen
 * @since 2023-05-15
 */
@RestController
@Api(tags = "会员管理")
@Slf4j
@RequestMapping("/sys_user")
public class SysUserController {
    @Autowired
    private ISysUserService iSysUserService;

    /**
     * 会员详情
     *
     * @param
     * @return
     */
    @GetMapping("/rowInfo")
    @ApiOperation(value = "会员详情")
    public Result<MemberManagementqueVo> getMerById(String id) {

        return iSysUserService.getMerById(id);
    }

    /**
     * 会员分页查询
     *
     * @param
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "会员分页查询")
    public Result<MemberManagementpageVo> Memberlist(MemberManagementPageDTO dto) {
        //log.info("分页查询: {}", dto);
        Result<MemberManagementpageVo> page = iSysUserService.page(dto);
        return page;
    }

    /**
     * 新增
     *
     * @param
     * @return
     */
    @PostMapping("/add")
    @ApiOperation(value = "新增")
    public Result add(@RequestBody MemberManagementAddDTO memberManagementAddDTO) {
        //log.error("新增: {}", memberManagementAddDTO);
        iSysUserService.add(memberManagementAddDTO);
        return Result.success();
    }

    /**
     * 删除
     *
     * @param
     * @return
     */
    @GetMapping("/del")
    @ApiOperation(value = "删除")
    public Result del(String id) {
        //log.error("删除: {}", id);
        iSysUserService.del(id);
        return Result.success();
    }

    /**
     * 修改
     *
     * @param
     * @return
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改")
    public Result del(@RequestBody MemberManagementUpDTO memberManagementUpDTO) {
        log.error("修改aaaaaaaaaaaaaaaaaaaaaaaaa: {}", memberManagementUpDTO);
        iSysUserService.updata(memberManagementUpDTO);
        return Result.success();
    }
}
